﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace BEGDC.EMISWeb.Sample
{
    public partial class Sample : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                //BEGDC.MIS.Business.Common.IUser service = (BEGDC.MIS.Business.Common.IUser)BEGDC.Utility.Castle.AppContainer.Instance["UserService"];
                //this.GridView1.DataSource = service.GetRoles();
                //this.GridView1.DataBind();
            }
        }

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                
                e.Row.Attributes.Add("onmouseover", "this.className='table_row_over'");
                if (e.Row.RowIndex % 2 == 0)
                    e.Row.Attributes.Add("onmouseout", "this.className='" + this.GridView1.RowStyle.CssClass + "'");
                else
                    e.Row.Attributes.Add("onmouseout", "this.className='" + this.GridView1.AlternatingRowStyle.CssClass + "'");

                e.Row.Attributes.Add("onClick ", "javascript:__doPostBack('" + GridView1.ID + "', 'Select$" + e.Row.RowIndex + "'); "); 

            }

        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.GridView1.SelectedRow.Attributes["onmouseout"] = "this.className='" + this.GridView1.SelectedRowStyle.CssClass + "'";
        }

        protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            if (this.GridView1.SelectedRow == null)
                return;

            if (this.GridView1.SelectedRow.RowIndex % 2 == 0)
                this.GridView1.SelectedRow.Attributes.Add("onmouseout", "this.className='" + this.GridView1.RowStyle.CssClass + "'");
                else
                this.GridView1.SelectedRow.Attributes.Add("onmouseout", "this.className='" + this.GridView1.AlternatingRowStyle.CssClass + "'");
        }
    }
}
